import React from "react";
import './index.scss';
import { getData } from "@/api/commonApi";
import { message } from 'antd';
class I7bFooter extends React.Component<any, any>{
    constructor(props: any) {
        super(props);

        this.state = {
            copyright: "",
            rightData: {
                title: "",
                subs: [],
            },
            leftData: [],
        }
    }
    componentDidMount() {
        this.getFooterData();
    }
    render() {
        return (
            <div className="i-f">
                <div className="i-f-t common-width">
                    <div className="i-f-t-l">
                        <ul>
                            {this.state.leftData.map((item: any, inx: number) => {
                                return (
                                    <li key={inx}>
                                        <h5>{item.title}</h5>
                                        {item.subs.map((t1: any, i1: number) => {
                                            return (
                                                <p key={i1} onClick={this.goPath.bind(this, t1)}>{t1.text}</p>
                                            )
                                        })}
                                    </li>
                                )
                            })}
                        </ul>
                    </div>
                    <div className="i-f-t-r">
                        <h5>{this.state.rightData.title}</h5>
                        {this.state.rightData.subs.map((item: any, inx: number) => {
                            return (
                                <p key={inx}>{item.text}</p>
                            )
                        })}
                    </div>
                </div>
                <p className="i-f-p">
                    {this.state.copyright}
                </p>
            </div>
        )
    }

    // 跳转路由
    goPath(item: any) {
        message.warning(`当前模块：${item.text}，页面开发中！`);
    }


    // 获取所有数据
    async getFooterData() {
        let res: any = await getData('footerData');
        if (!res || res.data.length === 0) {
            return false;
        }
        let data = res.data[0];
        this.setState({
            copyright: data.copyright,
            rightData: data.rightData,
            leftData: data.leftData
        })

    }
}
export default I7bFooter;